#!/bin/bash 
#安装go语言环境
#install go env

shdir=`dirname $0`

DIR=$shdir/`date +%Y%m%d`
#go语言源码包
GO_SRC="https://dl.google.com/go/go1.14.3.linux-amd64.tar.gz"
GO_FILE=${GO_SRC##*/}
M_PROFILE=$HOME/.profile

echo $GO_FILE

if [ ! -d $DIR ];then
	mkdir $DIR
fi

cd $DIR 

echo "开始安装go环境"
echo "下载go源码包"
wget $GO_SRC

echo "解压源码包"
sudo tar -C /usr/local -zxvf $GO_FILE
echo "export PATH=\$PATH:/usr/local/go/bin/ #添加go语言环境变量到PATH">>$M_PROFILE

echo "安装完成"
echo "在模拟终端运行source /home/yhp/.profile立即更新变量或者注销用户重新登录以更新PATH"

rm -rf $DIR
